﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CaptureImageMergeSys
{
    public partial class VideoPanel : Form
    {
        public VideoPanel()
        {
            InitializeComponent();
            this.TopLevel = false;
            LoadInputVideoPanel();
            LoadOutputVideoWnd();
        }
        private void LoadOutputVideoWnd()
        {
            m_wndOutputVideo = new OutputVideoWnd();
            OutputVideoPanel.Controls.Add(m_wndOutputVideo);
            m_wndOutputVideo.Dock = System.Windows.Forms.DockStyle.Fill;
            m_wndOutputVideo.Show();
        }
        void LoadInputVideoPanel()
        {
            InputVideoWndsplitContainer1.SplitterDistance = this.Width / 2;
            m_wndInputVideoA = new InputVideoWnd( "DeviceA" );
            this.InputVideoWndsplitContainer1.PerformLayout();
            this.InputVideoWndsplitContainer1.Panel1.Controls.Add(m_wndInputVideoA);
            m_wndInputVideoA.Dock = System.Windows.Forms.DockStyle.Fill;
            m_wndInputVideoA.Show();
            m_wndInputVideoB = new InputVideoWnd("DeviceB");
            m_wndInputVideoB.Dock = System.Windows.Forms.DockStyle.Fill;
            this.InputVideoWndsplitContainer1.Panel2.Controls.Add(m_wndInputVideoB);
            m_wndInputVideoB.Show();
        }

        private InputVideoWnd m_wndInputVideoA;
        private InputVideoWnd m_wndInputVideoB;
        private OutputVideoWnd m_wndOutputVideo;

        private void VideoPanel_Resize(object sender, EventArgs e)
        {
            InputVideoWndsplitContainer1.SuspendLayout();
            InputVideoWndsplitContainer1.SplitterDistance = this.Width / 2;
            InputVideoWndsplitContainer1.Width = this.Width - 28;
            InputVideoWndsplitContainer1.ResumeLayout();
            this.InputVideoBPrompt.Location = new System.Drawing.Point(this.Width / 2 + 14,this.InputVideoBPrompt.Location.Y);
            OutputVideoPanel.Location = new System.Drawing.Point(InputVideoWndsplitContainer1.Location.X, OutputVideoPanel.Location.Y);
            OutputVideoPanel.Width = InputVideoWndsplitContainer1.Width;
            InputVideoWndsplitContainer1.SplitterDistance = this.Width / 2;
            
        }

        public bool StartVideo()
        {
            return m_wndInputVideoA.StartVideo() && m_wndInputVideoB.StartVideo();
        }

        public bool StopVideo()
        {
            return m_wndInputVideoA.StopVideo() && m_wndInputVideoB.StopVideo();
        }
    }
}
